window.$config = {
    host: location.hostname=='h5.oeeee.com' ? '' : '/sever',
    rex:{
        tel : /^1[34578]\d{9}$/
    },
    // 滚动到顶部
    toTop: function (func) {
        var timer = setInterval(function(){
            //获取滚动条距离顶部高度
            var osTop = document.documentElement.scrollTop || document.body.scrollTop;
            var ispeed = Math.floor(-osTop / 7);

            document.documentElement.scrollTop = document.body.scrollTop = osTop+ispeed;
            //到达顶部，清除定时器
            if (osTop == 0) {
                clearInterval(timer);
                if(func){
                    func();
                }
            };
        },30);
    },
    toRequestUrl: function(obj) {
        var str = [];
        for(var p in obj){
            str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
        }
        return str.join("&");
    },
    iswx : function(){
        var ua = window.navigator.userAgent.toLowerCase();
        if(ua.match(/MicroMessenger/i) == 'micromessenger'){
            return true;
        }else{
            return false;
        }
    },
    wxShare : function(url, title, summary) {
        var config = oe_wxconfig,
            title = title ? title : "妈妈，母亲节快乐，请收下我的一份诚心的祝福。",
            summary = summary ? summary : "打开页面，就能看到我的照片及对您说的悄悄话。",
            link = url ? url : location.href,
            thumb = "http://h5.oeeee.com/h5/motherday/icon.jpg",
            content = {
                title: title,
                desc:summary,
                link: link,
                imgUrl:thumb,
                type: '',
                dataUrl: '',
                success: function () {},
                cancel: function () {}
            }

        wx.config({
            debug: false,
            appId: config.appId,
            timestamp: config.timestamp,
            nonceStr: config.nonceStr,
            signature: config.signature,
            jsApiList: [
                'onMenuShareAppMessage','onMenuShareTimeline','onMenuShareQQ','onMenuShareWeibo'
            ]
        });
        wx.checkJsApi({
            jsApiList: ['onMenuShareAppMessage','onMenuShareTimeline','onMenuShareQQ','onMenuShareWeibo'],
            success: function(res) {}
        });
        wx.ready(function () {
            wx.onMenuShareAppMessage(content);
            wx.onMenuShareTimeline(content);
            wx.onMenuShareQQ(content);
            wx.onMenuShareWeibo(content);
        });
    }
}